/*
 * @Author: OBKoro1
 * @Date: 2025-09-11 09:21:14
 * @LastEditTime: 2025-09-19 09:03:23
 * @FilePath: \RoPet_ESPS3_AI_EYE-main\main\main.cc
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
 */
#include <esp_log.h>
#include <esp_err.h>
#include <nvs.h>
#include <nvs_flash.h>
#include <driver/gpio.h>
#include <esp_event.h>

#include "application.h"
#include "system_info.h"

#define TAG "main"

extern "C" void app_main(void)
{
    // Initialize the default event loop,默认事件循环
    ESP_ERROR_CHECK(esp_event_loop_create_default());

    // Initialize NVS flash for WiFi configuration
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {//检查NVS（Non-Volatile Storage）是否需要初始化或擦除。
        ESP_LOGW(TAG, "Erasing NVS flash to fix corruption");//nvs擦除
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);

    // Launch the application，启动应用程序
    Application::GetInstance().Start();
}
